﻿// See https://aka.ms/new-console-template for more information
//Console.WriteLine("Hello, World!");


var tel = new TelPhone(new DialImpl(), new ShutdownImpl());
tel.Dial("18010620509");
tel.Shutdown("18010620509");

Console.ReadLine();

/// <summary>
/// 单一职责原则
/// </summary>
public class TelPhone : IDial
{
    private readonly IDial _dial;
    private readonly IShutdown _shutdown;
    public TelPhone(IDial dial, IShutdown shutdown)
    {
        _dial = dial;
        _shutdown = shutdown;
    }

    public void Dial(string nubmer)
    {
        _dial.Dial(nubmer);
    }
    public void Shutdown(string nubmer)
    {
        _shutdown.Shutdown(nubmer);
    }
}

public interface IDial
{
    public void Dial(string nubmer);
}
public interface IShutdown
{
    public void Shutdown(string nubmer);
}

public class DialImpl : IDial
{
    void IDial.Dial(string nubmer)
    {
        Console.WriteLine($"正在拨打：{nubmer}");
    }
}


public class ShutdownImpl : IShutdown
{
    void IShutdown.Shutdown(string nubmer)
    {
        Console.WriteLine($"正在关机：{nubmer}");
    }
}


